<%-- 
    Document   : register_background
    Created on : 12 Jan, 2013, 7:43:08 PM
    Author     : s
--%>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%@include file="connection.jsp" %>
<%@page import="java.sql.*" %>

   

<%!
String f_nm,l_nm,e_mail,pass,pack,mo_no;
int usertype;
Date dt;
long time;

%>
 
<%
    
    f_nm=(String)request.getParameter("f_nm");
    l_nm=(String)request.getParameter("l_nm");
    usertype=Integer.parseInt(request.getParameter("usertype"));
    e_mail=(String)request.getParameter("email");
    pass=(String)request.getParameter("pass");
    mo_no=(String)request.getParameter("mo_no");
    pack=(String)request.getParameter("package");
    time=System.currentTimeMillis();
    dt=new Date(time);
    
    Statement stmt=con.createStatement();
    ResultSet rs1 = stmt.executeQuery("select pac_id from package where pac_name='"+pack+"'");
    if(rs1.next())
        pack=rs1.getString(1);
    
    if(usertype==0)
    {
    pstmt=con.prepareStatement("insert into user values(NULL,?,?,?,DES_ENCRYPT(?),?,?,?)");
    pstmt.setString(1, e_mail);
    pstmt.setString(2, f_nm);
    pstmt.setString(3, l_nm);
    pstmt.setString(4, pass);
    pstmt.setString(5, mo_no);
    pstmt.setString(6, pack);
    pstmt.setDate(7, dt);
    pstmt.executeUpdate();
    pstmt.close();
    
    
//    response.sendRedirect("login_check.jsp?usrnm_nm="+e_mail+"&pwd_nm="+pass);
    //out.println("Successfully ran");
    //out.println("Go to "+"<a href='index.jsp'>Home Page</a>");
    }
    else
    {
        pstmt=con.prepareStatement("insert into expert values(NULL,?,?,?,?,DES_ENCRYPT(?),?,?)");
    pstmt.setString(1, f_nm);
    pstmt.setString(2, l_nm);
    pstmt.setString(3, mo_no);
    pstmt.setString(4, e_mail);
    pstmt.setString(5, pass);
    pstmt.setString(6, pack);
    pstmt.setDate(7, dt);
    pstmt.executeUpdate();
    pstmt.close();
    
    
//    response.sendRedirect("login_check.jsp?usrnm_nm="+e_mail+"&pwd_nm="+pass);
    }
%>
